<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <title>服务设备</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=e9c5bb62">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=66b457d6">
    <style>
        table input {
            border: none;
            width: 100%;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        input[type=text], input[type=tel], input[type=number], select {
            box-sizing: border-box;
            border-width: 0px;
            border-style: none;
            padding-right: 0px !important;
            padding-top: 0px !important;
            padding-bottom: 0px !important;
            margin-left: 0px !important;
            margin-right: 0px !important;
            margin-top: 0px !important;
            margin-bottom: 0px !important;
            padding-left: 6px;
        }

        input[type=text], input[type=tel], input[type=number], select {
            height: 24px;
            width: 100%;
            border: none;
            outline: none;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
</head>

<body>
<section class="content" id="app" v-cloak=>
    <div class="div-td-content-more"><i></i></div>
    <div id="div" style="margin-top: 12px">
        <div style="float: left">
            <div class="box-body no-padding iframeH2" style="overflow: auto;margin-left: -10px;margin-top:-20px"
                 id="scrollDiv">
                <div id="progress" class="wyui-progress"></div>
                <table class="table  table-bordered text-center" id="week" >
                    <th colspan="6" style="min-width: 300px;width:1155px;height: 30px;background-color:#F2F2F2"><span
                            style="text-align:center;height:18px">设备信息</span></th>
                    <tr class="td-row2 td-value" style="height:30px;">
                        <td style="width: 190px;color:black;background-color:#F8F8F8">公司名称</td>
                        <td style="width: 190px;" ><select id="testCom" style="width:190px;" v-model="selectCom" @change="getType"  >
                           <!--<option  v-model="selectCom" v-if="customer.companyName!=''" >{{customer.companyName}}</option>-->
                            <option  value="公司名称" v-if="type=='edit'">{{customer.companyName}}</option>
                            <option  value="公司名称" v-else>请选择公司名称</option>
                            <option v-for="itemC in itemsCom" v-bind:value="itemC.id">{{itemC.name}}</option>
                        </select></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">自销/转入</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.saledType"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">设备类型</td>
                        <td ><select id="testType" style="width:190px;" v-model="selectType" @change="getBran" >
                           <option id="selType" value="请选择设备类型" v-if="type=='edit'">{{customer.deviceTypeName}}</option>
                            <option value="请选择设备类型" v-else>请选择设备类型</option>
                            <option v-for="itemT in itemsType" v-bind:value="itemT.id">{{itemT.name}}</option>
                        </select></td>
                    </tr>
                    <tr class="td-row2 td-value" style="height:30px">
                        <td style="width: 190px;color:black;background-color:#F8F8F8">品牌</td>
                        <td><select id="testBran" style="width:190px;" v-model="selectBran" @change="getMod" >
                           <<option  id="selBran" value="请选择品牌" v-if="type=='edit'">{{customer.brandName}}</option>
                            <option value="请选择品牌" v-else>请选择品牌</option>
                            <option v-for="itemB in itemsBran" v-bind:value="itemB.id">{{itemB.brandName}}</option>
                        </select></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">型号</td>
                        <td><select id="testMod" style="width:190px;" v-model="selectMod" >
                         <option id="selMod" value="请选择型号" v-if="type=='edit'">{{customer.modelName}}</option>
                            <option value="请选择型号" v-else>请选择型号</option>
                            <option v-for="itemMo in itemsMod" v-bind:value="itemMo.id">{{itemMo.modelName}}</option>
                        </select></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">序列号</td>
                        <td style="width: 190px;" ><input type="text" v-model="customer.sequence"></td>
                    </tr>
                    <tr class="td-row2 td-value" style="height:30px">
                        <td style="width: 190px;color:black;background-color:#F8F8F8">出厂年份</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.years" @focus="showDatePicker($event,i)"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">小时数</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.hours"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">配置</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.configuration"></td>
                    </tr>
                    <th colspan="6" style="min-width: 300px;width:1155px;height: 30px;background-color:#F2F2F2"><span
                            style="text-align:center;height:18px;background-color:#F8F8F8">客户信息</span></th>
                    <tr class="td-row2 td-value" style="height:30px">
                        <td style="width: 190px;color:black;background-color:#F8F8F8">客户姓名</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.customerName"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">客户电话</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.customerTel"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">设备管理员</td>
                        <td style="width: 190px;"><input type="text" v-model="customer.adminName"></td>
                    </tr>
                    <tr class="td-row2 td-value"style="height:30px">
                        <td style="width: 190px;color:black;background-color:#F8F8F8">设备管理员电话</td>
                        <td style="width: 190px"><input type="text" v-model="customer.adminTel"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">设备操作手</td>
                        <td style="width: 190px"><input type="text" v-model="customer.operatorName"></td>
                        <td style="width: 190px;color:black;background-color:#F8F8F8">设备操作手电话</td>
                        <td style="width: 190px"><input type="text" v-model="customer.operatorTel"></td>
                    </tr>
                    <tr class="td-row2 td-value"style="height:30px">
                        <td style="width: 190px;color:black;background-color:#F8F8F8">备注</td>
                        <td style="width: 190px;" colspan="5" ><input type="text" v-model="customer.remark" ></td>
                    </tr>
                </table>
                <input type="button" id="save" class="btn btn-primary btn-sm" @click="save(customer.id)" value="保存"
                       style="margin-left: 530px ;margin-top: 5px;width:60px;height: 30px">
                <input type="button" id="add" class="btn btn-primary btn-sm" @click="add" value="添加"
                       style="margin-left: 530px ;margin-top: 5px;width:60px;height: 30px">
                <input type="button" value="取消" class="btn btn-primary btn-sm" id="getBy" @click=close() style="margin-top: 5px;width:60px;height: 30px">
            </div>
        </div>

    </div>

</section>

</body>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=0b5caf39"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=0c4d95a9"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var app = new Vue({
        el: '#app',
        data: {
            customer:{
                id:'',
                companyName:'',
                fkCompanyId:'',
                fkBrandId:'',
                fkDeviceTypeId:'',
                fkModelId:'',
                saledType:'',
                deviceTypeName:'',
                brandName:'',
                modelName:'',
                years:'',
                hours:'',
                sequence:'',
                customerName:'',
                customerTel:'',
                adminName:'',
                adminTel:'',
                operatorName:'',
                operatorTel:'',
                remark:'',
                configuration:''
            },
            selectCom:'公司名称',
            selectType:'请选择设备类型',
            selectBran:'请选择品牌',
            selectMod:'请选择型号',
            templateCompanyId:'',
            templateDeviceTypeId:'',
            templateBrandId:'',
            templateModelId:'',
            type:'',
            itemsCom: [],
            itemsBran: [],
            itemsType:[],
            itemsMod: []
        },
        methods: {
            getType:function () {
                var that = this;
                var s = that.selectCom;
                that.selectType="请选择设备类型";
                that.selectBran="请选择品牌";
                that.selectMod="请选择型号";
                that.itemsBran="";
                that.itemsMod="";
                if(that.type="edit"){
                    that.type="";
                }
                $.wyui.postMethod('/deviceBrand/getDeviceTypeList.json', {}, function (r) {
                    $("#selType").hide();
                    $("#selBran").hide();
                    $("#selMod").hide();
                    that.itemsType = r.devicetypes;
                })

            },
            getBran:function () {
                var that = this;
                var s = that.selectType;
                /*var d = that.customer.fkCompanyId;
                if(""==that.customer.fkCompanyId){
                    d=getCurrentUser().companyId;
                }*/
                var d = that.selectCom;
                that.selectBran="请选择品牌";
                that.selectMod="请选择型号";
                that.itemsMod="";
                var data = {'deviceTypeId': s.toString(),'companyId':d};
                $.wyui.postMethod('/deviceModel/getBrandListByTypeId.json', data, function (r) {
                    console.log(r);
                    $("#selBran").hide();
                    $("#selMod").hide();
                    that.itemsBran = r.brands;
                })
            },
            getMod:function () {
                var that = this;
                var s = that.selectType;
                var d=that.selectBran;
                that.selectMod="请选择型号";
                var data = {'brandId':d,'deviceTypeId':s};
                $.wyui.postMethod('/deviceModel/getModelListByBrandId.json', data, function (r) {
                    console.log(r);
                    $("#selMod").hide();
                    that.itemsMod = r.models;
                })
            },
            add:function () {
                var that = this;
                that.customer.companyName=$("#testCom option:selected").text();
                that.customer.brandName=$("#testBran option:selected").text();
                that.customer.deviceTypeName=$("#testType option:selected").text();
                that.customer.modelName=$("#testMod option:selected").text();
                that.customer.fkCompanyId=that.selectCom;
                that.customer.fkDeviceTypeId=that.selectType;
                that.customer.fkBrandId=that.selectBran;
                that.customer.fkModelId=that.selectMod;
                if("公司名称"==that.customer.companyName){
                    alert("请选择公司名称")
                    return;
                }else if("请选择设备类型"==that.customer.deviceTypeName){
                    alert("请选择设备类型")
                    return;
                }else if("请选择品牌"==that.customer.brandName){
                    alert("请选择品牌")
                    return;
                }else if("请选择型号"==that.customer.modelName){
                  alert("请选择型号")
                    return;
                } else{
                    $.wyui.postMethod('/deviceService/add.json',trimRN(that.customer), function (r) {
                        alert("操作成功");
                        parent.refresh();
                        api.close();
                    })
                }

            },
            save:function (id) {
                var that=this;
                var that = this;
                that.customer.companyName=$("#testCom option:selected").text();
                that.customer.brandName=$("#testBran option:selected").text();
                that.customer.deviceTypeName=$("#testType option:selected").text();
                that.customer.modelName=$("#testMod option:selected").text();
                that.customer.fkCompanyId=that.selectCom;
                that.customer.fkDeviceTypeId=that.selectType;
                that.customer.fkBrandId=that.selectBran;
                that.customer.fkModelId=that.selectMod;
                if(that.selectCom=="公司名称"){
                    that.customer.fkCompanyId=that.templateCompanyId;
                }if(that.selectType=="请选择设备类型"){
                    that.customer.fkDeviceTypeId=that.templateDeviceTypeId;
                }
                if(that.selectBran=="请选择品牌"){
                    that.customer.fkBrandId=that.templateBrandId;
                }if(that.selectMod=="请选择型号"){
                    that.customer.fkModelId=that.templateModelId;
                }
                if("公司名称"==that.customer.companyName){
                    alert("请选择公司名称")
                    return;
                }else if("请选择设备类型"==that.customer.deviceTypeName){
                    alert("请选择设备类型")
                    return;
                }else if("请选择品牌"==that.customer.brandName){
                    alert("请选择品牌")
                    return;
                }else if("请选择型号"==that.customer.modelName){
                    alert("请选择型号")
                    return;
                } else{
                    $.wyui.postMethod('/deviceService/update.json',trimRN(that.customer), function (r) {
                        alert("保存成功");
                        parent.refresh();
                        api.close();
                    })
                }
            },
            close:function () {
                api.close();
            },
            showDatePicker: function (e, index) {
                var that = this;
                console.log(index)
                WdatePicker({
                    onpicked: function (dp) {
                        that.customer.years = dp.cal.getNewDateStr();
                        return true;
                    }
                });
                $(e.target).blur();
            },
        },
        mounted: function () {
            var that = this;
            if("edit"==$.wyui.page.urlParams.type){
                $("#add").hide();
                    $.wyui.postMethod('/companyBrand/findCompanyList.json', {}, function (r) {
                        console.log(r);
                        that.itemsCom = r.companies;
                    }),
                        $.wyui.postMethod('/deviceService/getById.json', {id:$.wyui.page.urlParams.id}, function (r) {
                            that.customer = r
                            that.customer.companyName=r.companyName;
                            that.selectCom="公司名称";
                            that.selectType="请选择设备类型";
                            that.selectBran="请选择品牌";
                            that.selectMod="请选择型号";
                            that.templateCompanyId=r.fkCompanyId;
                            that.templateDeviceTypeId=r.fkDeviceTypeId;
                            that.templateBrandId=r.fkBrandId;
                            that.templateModelId=r.fkModelId;
                            that.type="edit";

                })

            }else{
                $("#save").hide();
                $.wyui.postMethod('/companyBrand/findCompanyList.json', {}, function (r) {
                    console.log(r);
                    that.itemsCom = r.companies;
                });
            }


        }

    })


</script>

</html>